<!DOCTYPE html><html><head>
<title>uevent - User events</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.doctools_title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.doctools_section, LI.doctools_subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.doctools_example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.doctools_requirements LI, UL.doctools_syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.doctools_synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.doctools_syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.doctools_requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<!-- Generated from file 'uevent.man' by tcllib/doctools with format 'html'
   -->
<!-- Copyright &amp;copy; 2007-2012 Andreas Kupries &amp;lt;andreas_kupries@users.sourceforge.net&amp;gt;
   -->
<!-- uevent.n
   -->
<body><hr> [
   <a href="../../../../../../../../home">Tcllib Home</a>
&#124; <a href="../../../../toc.html">Main Table Of Contents</a>
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">uevent(n) 0.3.1 tcllib &quot;User events&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>uevent - User events</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
<li class="doctools_section"><a href="#section1">Description</a></li>
<li class="doctools_section"><a href="#section2">API</a></li>
<li class="doctools_section"><a href="#section3">Bugs, Ideas, Feedback</a></li>
<li class="doctools_section"><a href="#see-also">See Also</a></li>
<li class="doctools_section"><a href="#keywords">Keywords</a></li>
<li class="doctools_section"><a href="#category">Category</a></li>
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">Tcl 8.4</b></li>
<li>package require <b class="pkgname">uevent <span class="opt">?0.3.1?</span></b></li>
<li>package require <b class="pkgname">logger</b></li>
</ul>
<ul class="doctools_syntax">
<li><a href="#1"><b class="cmd">::uevent::bind</b> <i class="arg">tag</i> <i class="arg">event</i> <i class="arg">command</i></a></li>
<li><a href="#2"><b class="cmd"><a href="../../../../index.html#command">command</a></b> <i class="arg">tag</i> <i class="arg">event</i> <i class="arg">details</i></a></li>
<li><a href="#3"><b class="cmd">::uevent::unbind</b> <i class="arg">token</i></a></li>
<li><a href="#4"><b class="cmd">::uevent::generate</b> <i class="arg">tag</i> <i class="arg">event</i> <span class="opt">?<i class="arg">details</i>?</span></a></li>
<li><a href="#5"><b class="cmd">::uevent::list</b></a></li>
<li><a href="#6"><b class="cmd">::uevent::list</b> <i class="arg">tag</i></a></li>
<li><a href="#7"><b class="cmd">::uevent::list</b> <i class="arg">tag</i> <i class="arg">event</i></a></li>
<li><a href="#8"><b class="cmd">::uevent::watch::tag::add</b> <i class="arg">pattern</i> <i class="arg">command</i></a></li>
<li><a href="#9"><b class="cmd">{*}command</b> <b class="const">bound</b> <i class="arg">tag</i></a></li>
<li><a href="#10"><b class="cmd">{*}command</b> <b class="const">unbound</b> <i class="arg">tag</i></a></li>
<li><a href="#11"><b class="cmd">::uevent::watch::tag::remove</b> <i class="arg">token</i></a></li>
<li><a href="#12"><b class="cmd">::uevent::watch::event::add</b> <i class="arg">tag_pattern</i> <i class="arg">event_pattern</i> <i class="arg">command</i></a></li>
<li><a href="#13"><b class="cmd">{*}command</b> <b class="const">bound</b> <i class="arg">tag</i> <i class="arg">event</i></a></li>
<li><a href="#14"><b class="cmd">{*}command</b> <b class="const">unbound</b> <i class="arg">tag</i> <i class="arg">event</i></a></li>
<li><a href="#15"><b class="cmd">::uevent::watch::event::remove</b> <i class="arg">token</i></a></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>
<p>This package provides a general facility for the handling of user
events. Allows the binding of arbitrary commands to arbitrary events
on arbitrary tags, removal of bindings, and event generation.</p>
<p>The main difference to the event system built into the Tcl/Tk core is
that the latter can generate only virtual events, and only for
widgets. It is not possible to use the builtin facilities to bind to
events on arbitrary (pseudo-)objects, nor is it able to generate
events for such.</p>
<p>Here we can, by assuming that each object in question is represented
by its own tag. Which is possible as we allow arbitrary tags.</p>
<p>More differences:</p>
<ol class="doctools_enumerated">
<li><p>The package uses only a two-level hierarchy, tags and events, to
handle everything, whereas the Tcl/Tk system uses three levels, i.e.
objects, tags, and events, with a n:m relationship between objects and
tags.</p></li>
<li><p>This package triggers all bound commands for a tag/event combination,
and they are independent of each other. A bound command cannot force
the event processing core to abort the processing of command coming
after it.</p></li>
</ol>
</div>
<div id="section2" class="doctools_section"><h2><a name="section2">API</a></h2>
<p>The package exports eight commands, as specified below. Note that when
the package is used from within Tcl 8.5+ all the higher commands are
ensembles, i.e. the :: separators can be replaceed by spaces.</p>
<dl class="doctools_definitions">
<dt><a name="1"><b class="cmd">::uevent::bind</b> <i class="arg">tag</i> <i class="arg">event</i> <i class="arg">command</i></a></dt>
<dd><p>Using this command registers the <i class="arg">command</i> prefix to be triggered
when the <i class="arg">event</i> occurs for the <i class="arg">tag</i>. The result of the
command is an opaque token representing the binding. Note that if the
same combination of &lt;<i class="arg">tag</i>,<i class="arg">event</i>,<i class="arg">command</i>&gt; is used
multiple times the same token is returned by every call.</p>
<p>The signature of the <i class="arg">command</i> prefix is</p>
<dl class="doctools_definitions">
<dt><a name="2"><b class="cmd"><a href="../../../../index.html#command">command</a></b> <i class="arg">tag</i> <i class="arg">event</i> <i class="arg">details</i></a></dt>
<dd></dd>
</dl>
<p>where <i class="arg">details</i> contains the argument(s) of the event. Its
contents are event specific and have to be agreed upon between actual
event generator and consumer. This package simply transfers the
information and does not perform any processing beyond that.</p></dd>
<dt><a name="3"><b class="cmd">::uevent::unbind</b> <i class="arg">token</i></a></dt>
<dd><p>This command releases the event binding represented by the
<i class="arg">token</i>. The token has to be the result of a call to
<b class="cmd">::uevent::bind</b>. The result of the command is the empty string.</p></dd>
<dt><a name="4"><b class="cmd">::uevent::generate</b> <i class="arg">tag</i> <i class="arg">event</i> <span class="opt">?<i class="arg">details</i>?</span></a></dt>
<dd><p>This command generates an <i class="arg">event</i> for the <i class="arg">tag</i>, triggering
all commands bound to that combination. The <i class="arg">details</i> argument is
simply passed unchanged to all event handlers. It is the
responsibility of the code generating and consuming the event to have
an agreement about the format and contents of the information carried
therein. The result of the command is the empty string.</p>
<p>Note that all bound commands are triggered, independently of each
other. The event handlers cannot assume a specific order. They are
also <em>not</em> called synchronously with the invokation of this
command, but simply put into the event queue for processing when the
system returns to the event loop.</p>
<p>Generating an event for an unknown tag, or for a
&lt;<i class="arg">tag</i>,<i class="arg">event</i>&gt; combination which has no commands bound to it
is allowed, such calls will be ignored.</p></dd>
<dt><a name="5"><b class="cmd">::uevent::list</b></a></dt>
<dd><p>In this form the command returns a list containing the names of all
tags which have events with commands bound to them.</p></dd>
<dt><a name="6"><b class="cmd">::uevent::list</b> <i class="arg">tag</i></a></dt>
<dd><p>In this format the command returns a list containing the names of all
events for the <i class="arg">tag</i> with commands bound to them. Specifying an
unknown tag, i.e. a tag without event and commands, will cause the
command to throw an error.</p></dd>
<dt><a name="7"><b class="cmd">::uevent::list</b> <i class="arg">tag</i> <i class="arg">event</i></a></dt>
<dd><p>In this format the command returns a list containing all commands
bound to the <i class="arg">event</i> for the <i class="arg">tag</i>. Specifying an unknown tag
or unknown event, will cause the command to throw an error.</p></dd>
<dt><a name="8"><b class="cmd">::uevent::watch::tag::add</b> <i class="arg">pattern</i> <i class="arg">command</i></a></dt>
<dd><p>This command sets up a sort of reverse events. Events generated,
i.e. the <i class="arg">command</i> prefix invoked, when observers bind to and
unbind from specific tags.</p>
<p>Note that the command prefix is only invoked twice per tag,
first when the first command is bound to any event of the tag, and
second when the last command bound to the tag is removed.</p>
<p>The signature of the <i class="arg">command</i> prefix is</p>
<dl class="doctools_definitions">
<dt><a name="9"><b class="cmd">{*}command</b> <b class="const">bound</b> <i class="arg">tag</i></a></dt>
<dd></dd>
<dt><a name="10"><b class="cmd">{*}command</b> <b class="const">unbound</b> <i class="arg">tag</i></a></dt>
<dd></dd>
</dl>
<p>The result of the command is a token representing the watcher.</p></dd>
<dt><a name="11"><b class="cmd">::uevent::watch::tag::remove</b> <i class="arg">token</i></a></dt>
<dd><p>This command removes a watcher for (un)bind events on tags.</p>
<p>The result of the command is the empty string.</p></dd>
<dt><a name="12"><b class="cmd">::uevent::watch::event::add</b> <i class="arg">tag_pattern</i> <i class="arg">event_pattern</i> <i class="arg">command</i></a></dt>
<dd><p>This command sets up a sort of reverse events. Events generated,
i.e. the <i class="arg">command</i> prefix invoked, when observers bind to and
unbind from specific combinations of tags and events.</p>
<p>Note that the command prefix is only invoked twice per
tag/event combination, first when the first command is bound to it,
and second when the last command bound to the it is removed.</p>
<p>The signature of the <i class="arg">command</i> prefix is</p>
<dl class="doctools_definitions">
<dt><a name="13"><b class="cmd">{*}command</b> <b class="const">bound</b> <i class="arg">tag</i> <i class="arg">event</i></a></dt>
<dd></dd>
<dt><a name="14"><b class="cmd">{*}command</b> <b class="const">unbound</b> <i class="arg">tag</i> <i class="arg">event</i></a></dt>
<dd></dd>
</dl>
<p>The result of the command is a token representing the watcher.</p></dd>
<dt><a name="15"><b class="cmd">::uevent::watch::event::remove</b> <i class="arg">token</i></a></dt>
<dd><p>This command removes a watcher for (un)bind events on tag/event
combinations.</p>
<p>The result of the command is the empty string.</p></dd>
</dl>
</div>
<div id="section3" class="doctools_section"><h2><a name="section3">Bugs, Ideas, Feedback</a></h2>
<p>This document, and the package it describes, will undoubtedly contain
bugs and other problems.
Please report such in the category <em>uevent</em> of the
<a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>.
Please also report any ideas for enhancements you may have for either
package and/or documentation.</p>
<p>When proposing code changes, please provide <em>unified diffs</em>,
i.e the output of <b class="const">diff -u</b>.</p>
<p>Note further that <em>attachments</em> are strongly preferred over
inlined patches. Attachments can be made by going to the <b class="const">Edit</b>
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar.</p>
</div>
<div id="see-also" class="doctools_section"><h2><a name="see-also">See Also</a></h2>
<p><a href="../hook/hook.html">hook(n)</a></p>
</div>
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../../../index.html#bind">bind</a>, <a href="../../../../index.html#event">event</a>, <a href="../../../../index.html#generate_event">generate event</a>, <a href="../../../../index.html#hook">hook</a>, <a href="../../../../index.html#unbind">unbind</a></p>
</div>
<div id="category" class="doctools_section"><h2><a name="category">Category</a></h2>
<p>Programming tools</p>
</div>
<div id="copyright" class="doctools_section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2007-2012 Andreas Kupries &lt;andreas_kupries@users.sourceforge.net&gt;</p>
</div>
</div></body></html>
